import { Platform, Dimensions } from 'react-native';
/**
 * 图片资源
 */
const ImageRes = {
    /** tabbar */
    tab_team_sel: require('../images/tab/tab_team_sel.png'),
    tab_team_un_sel: require('../images/tab/tab_team_un_sel.png'),
    tab_profit_sel: require('../images/tab/tab_profit_sel.png'),
    tab_profit_un_sel: require('../images/tab/tab_profit_un_sel.png'),
    tab_personal_sel: require('../images/tab/tab_personal_sel.png'),
    tab_personal_un_sel: require('../images/tab/tab_personal_un_sel.png'),

    /** Team */
    team_header: require('../images/team/team_header.png'),
    team_header_bottom: require('../images/team/team_header_bottom.png'),
    team_manager: require('../images/team/team_manager.png'),
    team_rank: require('../images/team/team_rank.png'),
    team_price_bg: require('../images/team/team_price_bg.png'),
    team_manager_bg: require('../images/team/team_manager_bg.png'),
    team_rank_bg: require('../images/team/team_rank_bg.png'),
    team_right_arrow: require('../images/team/team_right_arrow.png'),
    team_shadow: require('../images/team/team_shadow.png'),
    team_notify: require('../images/team/team_notify.png'),
    team_serch: require('../images/team/team_serch.png'),
    team_back: require('../images/team/team_back.png'),
    team_setting: require('../images/team/team_setting.png'),
    team_no_auth: require('../images/team/team_no_auth.png'),
    team_user: require('../images/team/team_user.png'),
    team_phone: require('../images/team/team_phone.png'),
    team_rate: require('../images/team/team_rate.png'),
    team_exachange: require('../images/team/team_exachange.png'),
    team_crown: require('../images/team/team_crown.png'),
    team_rank_default_header: require('../images/team/team_rank_default_header.png'),
    team_rank_head: require('../images/team/team_rank_head.png'),
    team_rank_one: require('../images/team/team_rank_one.png'),
    team_rank_two: require('../images/team/team_rank_two.png'),
    team_rank_three: require('../images/team/team_rank_three.png'),

    /** Profit */
    profit_down: require('../images/profit/profit_down.png'),
    profit_no_data: require('../images/profit/profit_no_data.png'),
    profit_bg: require('../images/profit/profit_bg.png'),
    profit_money: require('../images/profit/profit_money.png'),
    profit_delete: require('../images/profit/profit_delete.png'),
    profit_result: require('../images/profit/profit_result.png'),
    profit_daily: require('../images/profit/profit_daily.png'),
    profit_jiang: require('../images/profit/profit_jiang.png'),
    profit_huan: require('../images/profit/profit_huan.png'),
    
    /** Personal */
    personal_bg: require('../images/personal/personal_bg.png'),
    personal_default_header: require('../images/personal/personal_default_header.png'),
    personal_default_setting: require('../images/personal/personal_default_setting.png'),
    personal_default_setting: require('../images/personal/personal_default_setting.png'),
    personal_bank: require('../images/personal/personal_bank.png'),
    personal_auth: require('../images/personal/personal_auth.png'),
    personal_notify: require('../images/personal/personal_notify.png'),
    personal_share: require('../images/personal/personal_share.png'),
    personal_feedback: require('../images/personal/personal_feedback.png'),
    personal_about: require('../images/personal/personal_about.png'),
    personal_exit: require('../images/personal/personal_exit.png'),
    personal_tip: require('../images/personal/personal_tip.png'),
    personal_icon: require('../images/personal/personal_icon.png'),
    personal_select: require('../images/personal/personal_select.png'),
    personal_plus: require('../images/personal/personal_plus.png'),
    personal_check: require('../images/personal/personal_check.png'),
    personal_uncheck: require('../images/personal/personal_uncheck.png'),
    personal_camer: require('../images/personal/personal_camer.png'),
    personal_auth_one: require('../images/personal/personal_auth_one.png'),
    personal_auth_two: require('../images/personal/personal_auth_two.png'),
    personal_auth_three: require('../images/personal/personal_auth_three.png'),
    personal_auth_success: require('../images/personal/personal_auth_success.png'),
    personal_camer_id: require('../images/personal/personal_camer_id.png'),
    personal_my_rate: require('../images/personal/personal_my_rate.png'),
    icon_back_white: require('../images/personal/icon_back_white.png'),
    icon_back: require('../images/personal/icon_back.png'),
    
    /** Auth */
    show_password: require('../images/auth/show_password.png'),
    hide_password: require('../images/auth/hide_password.png'),

    /** version */
    version_bg: require('../images/version/alertViewVersion.png')
};

/**
 * 常用颜色
 */
const Colors = {
    bg_color: '#F3F3F3',
    white_color: '#FFFFFF',
    textCommonBlack: '#333333',
    textCommonGray: '#666666'
};

/**
 * 常用尺寸大小
 */
const Dimens = {
    OS: Platform.OS,
    isAndroid: Platform.OS === 'android',
    isIOS: Platform.OS === 'ios',
    DeviceWidth: Dimensions.get('window').width,
    DeviceHeight: Dimensions.get('window').height,
    isIPhoneX: Platform.OS === 'ios' && (Number(((Dimensions.get('window').height / Dimensions.get('window').width) + "").substr(0, 4)) * 100) === 216,
    NavBarHeight: Platform.OS === 'android' ? 50 : ((Platform.OS === 'ios' && (Number(((Dimensions.get('window').height / Dimensions.get('window').width) + "").substr(0, 4)) * 100) === 216) ? 94 : 70),
    StatusBarHeight: Platform.OS === 'android' ? 0 : ((Platform.OS === 'ios' && (Number(((Dimensions.get('window').height / Dimensions.get('window').width) + "").substr(0, 4)) * 100) === 216) ? 44 : 20),
    TabBarHeight: Platform.OS === 'android' ? 65 : ((Platform.OS === 'ios' && (Number(((Dimensions.get('window').height / Dimensions.get('window').width) + "").substr(0, 4)) * 100) === 216) ? 80 : 65),
}


export { ImageRes, Colors, Dimens, GetTimeStr, CheckPhone, getPovinceAndCityName, getPovinceAndCityId };


function GetTimeStr(time) {
    let date = new Date(time * 1000);
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
    return Y + M + D + h + m + s
}
function CheckPhone(phone) {
    let reg = /^[0-9]+.?[0-9]*$/;
    return !phone || phone.indexOf(1) !== 0 || phone.length !== 11 || !reg.test(phone)
}


function getPovinceAndCityName(sourceData, selected) {
    if (selected.length !== 2 || !sourceData) {
        return ['', '']
    }
    var province = selected[0]
    var city = selected[1]
    var provinceName = '',
        cityName = ''
    var citys = []
    sourceData.some(function (item) {
        if (item.id == province) {
            citys = item.city
            provinceName = item.name
            return true
        }
    })
    citys.some(function (item) {
        if (item.id == city) {
            cityName = item.name
            return true
        }
    })
    return [provinceName, cityName]
}


function getPovinceAndCityId(sourceData, selected) {
    if (selected.length !== 2 || !sourceData) {
        return ['', '']
    }
    var province = selected[0]
    var city = selected[1]
    var provinceId = '',
        cityId = ''
    var citys = []
    sourceData.some(function (item) {
        if (item.name === province) {
            citys = item.city
            provinceId = item.id
            return true
        }
    })
    citys.some(function (item) {
        if (item.name === city) {
            cityId = item.id
            return true
        }
    })
    return [provinceId, cityId]
}